﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Goodway.Dao.Utility;
using System.Xml.Linq;

namespace ExcelImportComponent.Valider.Implement
{
    public class ValidInt : IVaild
    {

        #region IVaild 成员

        public List<ExcelImportValidMessage> DoValid(string validColumnName, List<Goodway.Dao.Utility.GoodwayEntity> entities, XElement validSetting, string schemaname)
        {
            List<ExcelImportValidMessage> returnValue = new List<ExcelImportValidMessage>();
            string message = "必须为整数";
            for (int i = 0; i < entities.Count; i++)
            {
                GoodwayEntity entity = entities[i];
                int value = 0;
                bool valid = int.TryParse(entity[validColumnName], out value);
                if (!valid)
                {
                    ExcelImportValidMessage objMessage = new ExcelImportValidMessage(i.ToString(), validColumnName);
                    objMessage.Value = entity[validColumnName];
                    objMessage.ErrorMessage.Add(message);
                    returnValue.Add(objMessage);
                }
            }
            return returnValue;
        }

        #endregion
    }
}
